package lg.minecraft.plugin.cobblemoncore.config.mapping;

import com.cobblemon.mod.common.api.moves.MoveTemplate;
import com.cobblemon.mod.common.api.moves.Moves;
import lg.minecraft.plugin.cobblemoncore.LGCobblemonCore;
import lombok.Getter;

/**
 * @author langle__
 * @version 1.0
 */
@Getter
public class MoveMapping extends AbstractMapping<MoveTemplate> {

    public MoveMapping() {
        super(LGCobblemonCore.getInstance(), "move", LGCobblemonCore.getMappingDirectory().getPath());
    }

    @Override
    protected boolean isUseLocalFile() {
        return LGCobblemonCore.getMainConfig().isMove();
    }

    @Override
    protected void loadFromDynamicSource() {
        for (MoveTemplate moveTemplate : Moves.INSTANCE.all()) {
            String displayName = moveTemplate.getDisplayName().getString();
            set(moveTemplate.getName(), displayName);
            mapping.put(displayName, moveTemplate);
            reverse.put(moveTemplate, displayName);
        }
    }

    @Override
    protected void loadFromLocalFile() {
        for (MoveTemplate moveTemplate : Moves.INSTANCE.all()) {
            String displayName = moveTemplate.getDisplayName().getString();
            mapping.put(displayName, moveTemplate);
            reverse.put(moveTemplate, displayName);
        }
    }

}
